<%@page import="beans.customer.CustomerBean"%>
<%@ include  file="Header.jsp" %>   
<%@page import="java.sql.Types"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.CallableStatement"%>
<%@page import="java.sql.Connection"%>
<jsp:directive.page import="Connectivity.ConnectionManager"/>
<%@page import="beans.Contact"%>
<%@page import="java.util.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="display" uri="http://displaytag.sf.net" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
String cust_id = request.getParameter("cust_id")!=null?request.getParameter("cust_id"):"null";
String status = request.getParameter("status")!=null?request.getParameter("status"):"BACK";
String name = request.getParameter("name")!=null?request.getParameter("name"):"null";
String branch = request.getParameter("branch")!=null?request.getParameter("branch"):"null";
String submit = request.getParameter("submit")!=null?request.getParameter("submit"):"null";
String jspname = request.getParameter("jspname")!=null?request.getParameter("jspname"):"null";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>Search</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	        
	        <link rel="stylesheet" href="css/displaytag.css" type="text/css">
        <link rel="stylesheet" href="css/screen.css" type="text/css">
	<link rel="stylesheet" href="css/site.css" type="text/css">

  </head>
  <body>
  
<form name=clentdetailsreport method=post action="/Genius/form/report/SearchReport.jsp"  >
  <table align=center border=1  >
    <%
    if(status.equalsIgnoreCase("I"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> INSERTED SUCCESSFULLY </font> </td></tr>");
    }
     if(status.equalsIgnoreCase("U"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> UPDATED SUCCESSFULLY </font> </td></tr>");
    }
     if(status.equalsIgnoreCase("D"))
    {
    out.println("  <tr><td align=center width=100% colspan=10><font size=4 color=black> DELETED SUCCESSFULLY </font> </td></tr>");
    }
     %>
     
     
    <tr><td align=center   colspan=10><font size=4 color=Blue> CUSTOMER SEARCH</font></td></tr>
    <tr><td align=left colspan=5 >SEARCH BY NAME:&nbsp;&nbsp;&nbsp;</td>
   		<td align=left colspan=5><input type=name name= name value=""> </td>
   </tr>
   <tr><td align=left colspan=5 >SEARCH BY BRANCH/AREA:&nbsp;&nbsp;&nbsp;</td>
   		<td align=left  colspan=5><input type=text name=branch value=""> </td>
   </tr>
    <tr><td align=right  colspan=5 ><input type=submit name=submit value="search"> &nbsp;&nbsp;&nbsp;&nbsp;</td>
        <td align=left  colspan=5><input type=reset name=reset value="Reset"> </td>
    </tr>
    <input type=hidden name=status value=<%=status%>>
    <input type=hidden name=jspname value=<%=jspname%>>
   
    
 <%
 if(submit.equalsIgnoreCase("search")) 
 {
 
  String customerquerry="";
 
 if(name.length()>0)
 {
 
  customerquerry="select customer_id,customer_name,area,address1,phone_no1";
     customerquerry=customerquerry+",email_id,contactperson1,contactperson2,mobilecontact1,mobilecontact2 ";
	 customerquerry=customerquerry+" from customer_master where customer_name like '"+name.toUpperCase()+"%' and status='V' order by customer_id ";
  
     
 
 
 }
 else if(branch.length()>0)
 {
   
     customerquerry="select customer_id,customer_name,area,address1,phone_no1";
     customerquerry=customerquerry+",email_id,contactperson1,contactperson2,mobilecontact1,mobilecontact2 ";
	 customerquerry=customerquerry+" from customer_master where area like '"+branch.toUpperCase()+"%' and status='V' order by customer_id ";
  System.out.println("customerquerry:"+customerquerry);
 
 
 }
 else
 {
  
  customerquerry="select customer_id,customer_name,area,address1,phone_no1";
     customerquerry=customerquerry+",email_id,contactperson1,contactperson2,mobilecontact1,mobilecontact2 ";
	 customerquerry=customerquerry+" from customer_master where status='V' order by customer_id ";
  
 
 }
 
 
 
 prst1=con.prepareStatement(""+customerquerry);
  ResultSet rs1=prst1.executeQuery();
  
  List<CustomerBean> cbLst = new ArrayList<CustomerBean>();
  while(rs1.next())
  {
	  CustomerBean cb = new CustomerBean();
	  cb.setCustomerId(rs1.getString(1));
	  cb.setCustomerName(rs1.getString(2));
	  cb.setArea(rs1.getString(3));
	
	  cbLst.add(cb);
  }
  session.setAttribute("cbLst", cbLst);
%>

 
<%-- <tr>
<td align=left colspan=1><font size=2 color=grey><a href="/Genius/form/report/<%=jspname%>?cust_id=<%=rs1.getString(1).toUpperCase()%>&status=<%=status%>"><%=rs1.getString(1).toUpperCase() %></a></font></td>
<td align=left colspan=4><font size=2 color=grey><a href="/Genius/form/report/<%=jspname%>?cust_id=<%=rs1.getString(1).toUpperCase()%>&status=<%=status%>"><%=rs1.getString(2).toUpperCase() %></a> </td>
<td align=left colspan=4><font size=2 color=grey><a href="/Genius/form/report/<%=jspname%>?cust_id=<%=rs1.getString(1).toUpperCase()%>&status=<%=status%>"><%=rs1.getString(3).toUpperCase() %></a></td>
</tr> --%>
<tr><td colspan="9">
<div id='tab1' class="tab_content" style="display: block; width: 100%"> 
<display:table name="sessionScope.cbLst" pagesize="15" export="true" sort="list" uid="one" >
                
                <display:column property="customerId" title="Customer Id" sortable="true" headerClass="sortable" />
                <display:column property="customerName" title="CUSTOMER NAME" sortable="true" headerClass="sortable" />
                <display:column property="area" title="BRANCH NAME" sortable="true" headerClass="sortable" />

</display:table>
</div>

  <%
  }
	  
 %>
 </td></tr>
     </table>     
   </form>     
       
  
  
  
  
  
  </body>
</html>
